#ifndef _BL_SERIAL_H
#define _BL_SERIAL_H

#ident "$Id: serial.h,v 1.1 2008/03/17 08:02:33 zhulin Exp $"

#include "types.h"


typedef enum { /* Some useful SA-1100 baud rates */
	baud1k2 = 192,
	baud9k6 = 96,
	baud19k2 = 48,
	baud38k4 = 24,
	baud57k6 = 16,
	baud115k2 = 8
} eBauds;


/* Function protos */
void SerialInit(eBauds baudrate);

void SerialOutputByte(const unsigned char c);
void SerialOutputRawByte(const unsigned char c);
void SerialOutputString(const char *s);
void SerialOutputHex(const u32 h);
void SerialOutputByteInHex(const char c);
void SerialOutputDec(const u32 d);
void SerialOutputBlock(const char *buf, int bufsize);


int  SerialInputByte(char *c);
int  SerialInputString(char *s, const int len, const int timeout);
int  SerialInputBlock(char *buf, int bufsize, const int timeout);
int  SerialInputBlock_msec(char *buf, int bufsize, const int timeout_msec);
void  SerialInputFlush(void);
int  SerialInputStr(char *buf, int count);
int SerialInputDWordWithTimeout();

#ifdef DEBUG 
#define DebugOutputString(x) SerialOutputString(x)
#define DebugOutputByte(x) SerialOutputByte(x)
#define DebugOutputHex(x) SerialOutputHex(x)
#define DebugOutputByteInHex(x) SerialOutputByteInHex(x)
#define DebugOutputDec(x) SerialOutputDec(x)
#else
#define DebugOutputString(x) 
#define DebugOutputByte(x) 
#define DebugOutputHex(x) 
#define DebugOutputByteInHex(x) 
#define DebugOutputDec(x)
#endif




#endif



